package com.huawei.appgallery.wishwall.ui.fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import com.huawei.appgallery.foundation.store.bean.detail.DetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.Layout;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.wishwall.ui.cardkit.bean.WishWallDeleteCardBean;
import com.huawei.appgallery.wishwall.ui.cardkit.bean.WishWallListCardBean;
import com.huawei.appgallery.wishwall.ui.cardkit.bean.WishWallSubHeaderCardBean;
import java.util.ArrayList;
import java.util.List;
import o.cfv;
import o.cgi;
import o.chi;
import o.cie;
import o.cih;
import o.BaseRequest;
import o.ddq.f;
import o.ddu;

public class WishWallDeleteFragment extends AppListFragment {

    public interface c {
        void ˋ(@NonNull String str);

        void ˎ(@NonNull String str);
    }

    public void ॱﾟ() {
        if (this.ॱꜞ == null) {
            this.ॱꜞ = new chi();
        }
    }

    public void ˋ(ViewGroup viewGroup, LayoutInflater layoutInflater) {
        super.ˋ(viewGroup, layoutInflater);
        this.ߴ.setWarnImage(e.ˊ);
        this.ߴ.setWarnTextOne(ॱ(f.ॱ));
        this.ͺˎ.setOnItemClickListener(new OnItemClickListener(this) {
            final /* synthetic */ WishWallDeleteFragment ॱ;

            {
                this.ॱ = r1;
            }

            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                cie o_cie = (cie) view.getTag();
                if (o_cie != null) {
                    for (int i2 = 0; i2 < o_cie.ˊॱ(); i2++) {
                        cih ˎ = o_cie.ˎ(i2);
                        if (ˎ != null) {
                            this.ॱ.ˏ(ˎ);
                        }
                    }
                }
            }
        });
    }

    public void ˌॱ() {
    }

    public void ˋʼ() {
    }

    public cfv ˏ(String str, String str2, int i) {
        return cgi.ˏ("mypublistwishwall", str2, i);
    }

    public boolean ˊ(TaskFragment taskFragment, b bVar) {
        ˎ(bVar);
        return super.ˊ(taskFragment, bVar);
    }

    private void ˎ(b bVar) {
        BaseRequest o_cvu = bVar.ˊ;
        ResponseBean responseBean = bVar.ˋ;
        if ((o_cvu instanceof cfv) && (responseBean instanceof DetailResponse)) {
            cfv o_cfv = (cfv) o_cvu;
            DetailResponse detailResponse = (DetailResponse) responseBean;
            List ʻॱ = detailResponse.ʻॱ();
            List ᐝॱ = detailResponse.ᐝॱ();
            if (ʻॱ != null && ᐝॱ != null) {
                ˎ(ʻॱ, ᐝॱ);
                if (o_cfv.ˏ() == 1) {
                    ˏ(ʻॱ, ᐝॱ);
                    return;
                }
                return;
            }
            return;
        }
        ddu.ˊ.ˊ("WishWallDeleteFragment", "onResponse, req not instanceof DetailRequest or res not instanceof DetailResponse");
    }

    private void ˎ(List<Layout> list, List<LayoutData> list2) {
        for (Layout layout : list) {
            if ("wishwalllistcard".equals(layout.ˎ())) {
                layout.ˏ("wishwalldeletecard");
            }
        }
        for (LayoutData layoutData : list2) {
            if ("wishwalllistcard".equals(layoutData.ˏ())) {
                layoutData.ॱ("wishwalldeletecard");
                if (layoutData.ˋ() != null) {
                    List arrayList = new ArrayList();
                    for (Object next : layoutData.ˋ()) {
                        if (next instanceof WishWallListCardBean) {
                            arrayList.add(new WishWallDeleteCardBean((WishWallListCardBean) next));
                        }
                    }
                    layoutData.ॱ(arrayList);
                }
            }
        }
    }

    private void ˏ(List<Layout> list, List<LayoutData> list2) {
        Layout layout;
        int i;
        for (Layout layout2 : list) {
            if ("wishwallsubheadercard".equals(layout2.ˎ())) {
                return;
            }
        }
        for (LayoutData layoutData : list2) {
            if (("wishwalllistcard".equals(layoutData.ˏ()) || "wishwalldeletecard".equals(layoutData.ˏ())) && layoutData.ˋ() != null && !layoutData.ˋ().isEmpty()) {
                i = 1;
                break;
            }
        }
        i = 0;
        if (i != 0) {
            int i2 = 0;
            for (LayoutData layoutData2 : list2) {
                if (layoutData2.ˎ() == ((long) i2)) {
                    i = i2 + 1;
                } else {
                    i = i2;
                }
                i2 = i;
            }
            layout2 = new Layout();
            layout2.ॱ((long) i2);
            layout2.ˋ(-1);
            layout2.ˏ("wishwallsubheadercard");
            LayoutData layoutData3 = new LayoutData();
            layoutData3.ˋ((long) i2);
            layoutData3.ॱ("wishwallsubheadercard");
            List arrayList = new ArrayList();
            WishWallSubHeaderCardBean wishWallSubHeaderCardBean = new WishWallSubHeaderCardBean();
            wishWallSubHeaderCardBean.ˏ(ॱ(f.ʻॱ));
            arrayList.add(wishWallSubHeaderCardBean);
            layoutData3.ॱ(arrayList);
            list.add(0, layout2);
            list2.add(0, layoutData3);
        }
    }

    public void ˏ(int i, cih o_cih) {
        ˏ(o_cih);
    }

    private void ˏ(cih o_cih) {
        CardBean ˌ = o_cih.ˌ();
        if (ˌ instanceof WishWallDeleteCardBean) {
            WishWallDeleteCardBean wishWallDeleteCardBean = (WishWallDeleteCardBean) ˌ;
            FragmentActivity ॱˋ;
            if (wishWallDeleteCardBean.ˊ()) {
                wishWallDeleteCardBean.ˋ(false);
                ॱˋ = ॱˋ();
                if (ॱˋ instanceof c) {
                    ((c) ॱˋ).ˎ(wishWallDeleteCardBean.ʽ());
                }
            } else if (!wishWallDeleteCardBean.ˊ()) {
                wishWallDeleteCardBean.ˋ(true);
                ॱˋ = ॱˋ();
                if (ॱˋ instanceof c) {
                    ((c) ॱˋ).ˋ(wishWallDeleteCardBean.ʽ());
                }
            }
        }
        this.י.ͺ();
    }

    public void ʻ(int i) {
    }
}
